from exts import db
from datetime import datetime

#发布课题
class topica(db.Model):
    __tablename__ = "topica"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    content = db.Column(db.String(200), nullable=False)
    a_id = db.Column(db.Integer)
    # topicb=db.relationship("topicb",back_populates="topica",cascade="all")

class topicb(db.Model):
    __tablename__ = "topicb"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    content = db.Column(db.String(200), nullable=False)
    b_id = db.Column(db.Integer,db.ForeignKey("topicc.id"))
    #topica = db.relationship("topica", back_populates="topicb")

class topicc(db.Model):
    __tablename__ = "topicc"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    content = db.Column(db.String(200), nullable=False)
    c_id = db.Column(db.Integer,db.ForeignKey("topicd.id"))
    #topica = db.relationship("topica", back_populates="topicc")
class topicd(db.Model):
    __tablename__ = "topicd"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    content = db.Column(db.String(200), nullable=False)
    d_id = db.Column(db.Integer)
    #topica = db.relationship("topica", back_populates="topicd")

#留言板代码
class Todo(db.Model):
    __tablename__="todo"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    content = db.Column(db.String(200), nullable=False)
    person = db.Column(db.String(80), default="")
    pub_date = db.Column(db.DateTime, nullable=False, default=datetime.now)


#人员管理
class personnel(db.Model):
    __tablename__ = "personnel"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    school = db.Column(db.String(80), nullable=False)
    username = db.Column(db.String(80), nullable=False)
    password = db.Column(db.String(255), nullable=False)
    role=db.Column(db.String(80), nullable=False)
    phone=db.Column(db.String(30))
    p_id = db.Column(db.Integer,default=0)


#评价信息表
class ranking(db.Model):
    __tablename__ = "ranking"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    school = db.Column(db.String(80), nullable=False)
    topic_name = db.Column(db.String(80), nullable=False)
    bx_genre=db.Column(db.String(80), nullable=False)
    xx_genre=db.Column(db.String(80), nullable=False)
    score = db.Column(db.Integer, default=0)
    sid = db.Column(db.Integer, nullable=False)



#发布课题
class topic(db.Model):
    __tablename__ = "topic"
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    content = db.Column(db.String(80), nullable=False)
    pub_date = db.Column(db.DateTime, nullable=False, default=datetime.now)
    pub_person = db.Column(db.String(80),default="")